﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ArriendoVehiculo.LogicaNegocio;

namespace ArriendoVehiculo.Presentacion
{
    /// <summary>
    /// Lógica de interacción para fDevolucion.xaml
    /// </summary>
    public partial class fDevolucion : Window
    {
        public fDevolucion()
        {
            InitializeComponent();
        }

        private void RadioButton_Checked_1(object sender, RoutedEventArgs e)
        {
              
                if (check_no.IsChecked == true)
                {
                    txt_motivo.IsEnabled = true;
                }
        }

        private void RadioButton_Checked_2(object sender, RoutedEventArgs e)
        {
          
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (Validaciones.existeArriendo(txt_rut.Text))
            {
                var arr = Vehiculo.recivirArriendo(txt_rut.Text);
                txt_nombre.Text = arr.Cliente.Nombre;
                txt_apellido.Text = arr.Cliente.Apellido;
                txt_marca.Text = arr.Vehiculos.Marca.Marca1;
                txt_modelo.Text = arr.Vehiculos.Modelo.Modelo1;
                txt_color.Text = arr.Vehiculos.Color;
                btn_aceptar.IsEnabled = true;
            }
            else
            {

                MessageBox.Show("El cliente no tiene ningún arriendo vigente");
                btn_aceptar.IsEnabled = false;
            }
         
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (check_no.IsChecked==true)
            {
                Clientes.clieteEnListaNegra(txt_rut.Text, txt_motivo.Text);
                MessageBox.Show("El cliente se agrego a la lista negra","Lista negra",MessageBoxButton.OK,MessageBoxImage.Asterisk);
            }
               Vehiculo.devolucionAuto(txt_rut.Text);
               MessageBox.Show("Vehiculo entregado","Mensaje",MessageBoxButton.OK,MessageBoxImage.Information);
               txt_apellido.Text = "";
               txt_color.Text = "";
               txt_marca.Text = "";
               txt_modelo.Text = "";
               txt_motivo.Text = "";
               txt_nombre.Text = "";
               txt_rut.Text = "";
               btn_aceptar.IsEnabled = false;
        }
    }
}
